#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Author:Lijiacai
Email:1050518702@qq.com
===========================================
CopyRight@JackLee.com
===========================================
"""

import os
import sys
import json

import schedule

cur_dir = os.path.split(os.path.realpath(__file__))[0]
sys.path.append("%s/.." % cur_dir)
import config

sys.path.append("%s/../resource" % cur_dir)
from lijiacai.utils import tool


## 用户分层

def oracle_2_csv(conf: dict, apply_func=None):
    O2C = tool.Oracle2Csv()
    sql = conf.get("sql")
    start_end = ["2019-01-01", "2020-01-01"]
    sql = sql.format(start_end[1], start_end[0], start_end[1])
    index = "--".join(start_end)
    O2C.run(sql=sql, sql_fields=conf.get("fields"), index=index, apply_func=apply_func)
    O2C.close()


def customer():
    oracle_2_csv(conf=config.customer_RFM, apply_func=None)


if __name__ == '__main__':
    customer()
